﻿@{

    decimal d1 = 0m;
}
@using FwProject.Settlement.Dto
@using FwProject.Distribution.Dto
@model Tuple<SettlementReceivableDto, List<DistributionDto>>
@section styles{
    <style media="print" type="text/css">
        .Noprint {
            display: none;
        }

        .PageNext {
            page-break-after: always;
        }

        * {
            word-wrap: break-word;
            word-break: break-all;
        }

        body, td, th {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 12px;
            color: #1d1007;
            line-height: 20px;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0px;
        }
    </style>
    <link href="/css/print.css" rel="stylesheet" />
}

<!-----------------------------【smsx.cab】打印--------------------------->
<object id="factory" viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
        codebase="/scripts/smsx.cab#Version=6,2,433,70"></object>
<!-----------------------------【smsx.cab】打印--------------------------->
<form name="printformName" id="printformName" action="" method="post">
    <div align="center">
        <div id="printObj" style="width: 190mm" align="center">
            <style>
                table {
                    border-collapse: collapse;
                    border-spacing: 0px;
                }
            </style>

            <!-----------------------------【smsx.cab】打印--------------------------->
            <!--打印前初始化设置-->
            <script language="javascript">

                p_init({
                    portrait: true//true纵向,false横向
                });

            </script>

            <p>
                <input type="button" name="printBtn" class="notprint" value="打印" onclick="pagePrint();" />
            </p>
            <!-----------------------------【smsx.cab】打印--------------------------->
            <div align="center" id="titleSpan" style="font-size: 14px; margin-top: 3px; margin-bottom: 15px; font-weight: bold;">
                @*添富集团（测试）<br />*@
                收款单
            </div>

            <table width="100%" cellspacing="0" cellpadding="0" align="center" border="0">
                <tr>
                    <td width="10%"><b>单号</b>:</td>
                    <td>&nbsp;@Model.Item1.CreationNumber</td>
                    <td width="10%"><b>收款日期</b>:</td>
                    <td>&nbsp;@Model.Item1.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</td>

                </tr>
                <tr>
                    <td width="10%"><b>餐厅</b>:</td>
                    <td>&nbsp;@Model.Item1.RestaurantName</td>
                    <td><b>经办人</b>:</td>
                    <td>&nbsp;@Model.Item1.DriverName</td>
                </tr>
                <tr>
                    <td><b>收款金额</b>:</td>
                    <td>&nbsp;@Model.Item1.TotalPrice</td>
                    <td><b>优惠金额</b>:</td>
                    <td>&nbsp;@Model.Item1.Discountprice</td>
                </tr>
                <tr>
                    <td><b>备注</b>:</td>
                    <td colspan="3">&nbsp;根据配送单 @Model.Item1.CreationNumber 自动生成</td>
                </tr>
            </table>
            <br>
            <table width="100%" cellspacing="0" cellpadding="0" align="center" border=1 borderColor="black">
                <tr>
                    <td width="7%" align="center"><b>单据类型</b></td>
                    <td width="13%" align="center"><b>配送单号</b></td>
                    <td width="12%" align="center"><b>配送日期</b></td>
                    <td width="11%" align="center"><b>应收金额</b></td>
                    <td width="11%" align="center"><b>未收金额</b></td>
                    <td width="11%" align="center"><b>收款金额</b></td>
                    @*<td width="11%" align="center"><b>收款优惠</b></td>*@
                    <td width="15%" align="center"><b>备注</b></td>
                </tr>

                @foreach (var item in Model.Item2)
                {
                    <tr>
                        <td align="left">&nbsp; @item.RestaurantInfoModel.BalanceWay.ToString() &nbsp;</td>
                        <td align="left">&nbsp;@item.CreationNumber &nbsp;</td>
                        <td align="left">&nbsp;@item.CreationTime.ToString("yyyy-MM-dd")&nbsp;</td>
                        <td align="right">&nbsp;@item.TotalPrice&nbsp;</td>
                        <td align="right">&nbsp;@(item.TotalPrice - item.DistributionInfoListDetails.Sum(o => o.Sumprice))&nbsp;</td>
                        <td align="right">&nbsp;@item.DistributionInfoListDetails.Sum(o => o.Sumprice)&nbsp;</td>
                        @*<td align="right">&nbsp;0.00&nbsp;</td>*@
                        <td align="left">&nbsp;&nbsp;</td>
                    </tr>
                    d1 = d1 + item.DistributionInfoListDetails.Sum(o => o.Sumprice);
                }
                <tr>
                    <td align="center">&nbsp;<b>合计</b>&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;@d1&nbsp;</td>
                    @*<td align="right">&nbsp;0.00&nbsp;</td>*@
                    <td align="right">&nbsp;</td>

                </tr>
            </table>
            <hr />
            @*<table style='display:;' width="100%" cellspacing="0" cellpadding="0" align="center" border=0>
                    <tr>
                        <td width="30%" align="left"><b>[制单]</b>&nbsp;18824538026&nbsp;2018-05-14</td>
                        <td width="30%" align="left"><b>[提交]</b>&nbsp;&nbsp;</td>
                        <td width="30%" align="center"><b>[审核]</b>&nbsp;18824538026&nbsp;2018-05-14</td>
                    </tr>
                </table>*@

        </div>
    </div>
</form>

@section scripts{
    <script src="~/js/Print.js"></script>
    <script>
        var loadInfo = function () {
            var title = "收款收据";
            $('#titleSpan').text("@Model.Item1.RestaurantName"+":"+title);//标题
            //var table = window.opener.getInfo();
            //$('#valueSpanID').append(table);//打印内容
            //var printInit = window.opener.getprintInit();
            //if (!printInit.portrait) {//横打宽度为270mm
            //    $("#printObj").css({ "width": "270mm" });
            //}
            $("#printObj").css({ "width": "270mm" });
            p_init(printInit);
        };
        $(function () {
            loadInfo();
        });

        function pageSet() {
            try {
                p_pagesetup();
            } catch (e) {
                wb.execwb(8, 1);
            }
        }
        function pageView() {
            try {
                p_preview();
            } catch (e) {
                wb.execwb(7, 1);
            }
        }
        function pagePrint() {
            try {
                p_print();
            } catch (e) {
                wb.execwb(6, 6);
            }
        }
    </script>
}
